<?php
class CMRPageSubmit extends CMRPage
{
	protected function getContents()
	{
		$html = "<td>";
		$html .= "<h1>Submit a Resource</h1>";

		$hidden = new Hidden();
		$hidden->setName("SubAction");
		$html .= $hidden->getHTML();
		
		
//		echo $this->getSubAction();
		
		switch ($this->getSubAction())
		{
			case 'submitCreateArticle':
				$html .= $this->getCreateArticle();			
				break;
				
			case 'submitCreateChant':
				$html .= $this->getCreateChant();			
				break;
				
			case 'submitCreateComposer':
				$html .= $this->getCreateComposer();			
				break;
				
			case 'submitCreateLink':
				$html .= $this->getCreateLink();			
				break;
				
			case 'submitCreateRepertoire Item':
				$html .= $this->getCreateRepertoire();			
				break;
				
			case 'submitCreateScore':
				$html .= $this->getCreateScore();			
				break;
				
			default:
				$html .= $this->getDefault();			
				break;
		}
		

		$html .= "</td>";
		return $html;
				
	}
	private function getDefault()
	{
		$html = "<p>Select the type of resource you wish to add from the dropdown list below.</p>";
		$values = new Enumeration($this->Database,'CMRResourceTypes');
		$list = new DropDownListEnumeration($values->getArray());
		$list->setName("SubmitType");
		$html .= $list->getHTML();
		
		$button = new JavascriptButton();
		$button->setValue("Next");
		$button->setJavascript("var submitaction; submitaction='submitCreate'+(document.getElementById('SubmitType').options[document.getElementById('SubmitType').selectedIndex].text); document.getElementById('SubAction').value = submitaction; document.getElementById('pageForm').submit();");
		$html .= $button->getHTML();
		return $html;
		
	}

	private function getCreateArticle()
	{
		
	}
	
	private function getCreateChant()
	{
		
	}
	
	private function getCreateComposer()
	{
		$hidden = new Hidden();
		$hidden->setName("RecordID");
		$html = $hidden->getHTML();
		
		$hidden = new Hidden();
		$hidden->setName("DBTableName");
		$html .= $hidden->getHTML();
		
		$script = new UpdateRecordScript();
		$html .= $script->getHTML();
		$panel = new PanelEditDBRecord($this->Database,'CMRResources',-1);
		$panel->setTypeTable('CMRResourceTypeID','CMRComposers',3);
		$panel->setYearRange(1400,2020);
		$panel->setDateDisabler(true);
		$html .= $panel->getHTML();
		return $html;
	}
	
	private function getCreateLink()
	{
		
	}
	
	private function getCreateRepertoire()
	{
		$hidden = new Hidden();
		$hidden->setName("RecordID");
		$html = $hidden->getHTML();
		
		$hidden = new Hidden();
		$hidden->setName("DBTableName");
		$html .= $hidden->getHTML();
		
		$script = new UpdateRecordScript();
		$html .= $script->getHTML();
		$panel = new PanelEditDBRecord($this->Database,'CMRResources',-1);
		$panel->setTypeTable('CMRResourceTypeID','CMRRepertoireItems',2);
//		$panel->setYearRange(1400,2020);
		$html .= $panel->getHTML();
		return $html;
		
	}
	
	private function getCreateScore()
	{
		
	}
	
}
?>